<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickscreen.cpp -->
  <title>Screen QML 类型 | Qt Quick 5.12.3</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.12</a></td><td ><a href="qtquick-index.html">Qt Quick 模块</a></td><td ><a href="qtquick-qmlmodule.html">QML类型</a></td><td >Screen QML 类型</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtquick-index.html">Qt 5.12.3 参考指南</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#attached-properties">Attached Properties</a></li>
<li class="level1"><a href="#attached-methods">Attached Methods</a></li>
<li class="level1"><a href="#details">详细信息</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Screen QML 类型</h1>
<span class="subtitle"></span>
<!-- $$$Screen-brief -->
<p>The Screen attached object provides information about the Screen an Item or Window is displayed on. <a href="#details">更多...</a></p>
<!-- @@@Screen -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> 导入语句：</td><td class="memItemRight bottomAlign"> import QtQuick.Window 2.12</td></tr></table></div><ul>
<li><a href="qml-qtquick-window-screen-members.html">所有成员的列表，包括继承成员</a></li>
<li><a href="qml-qtquick-window-screen-obsolete.html">废弃的成员</a></li>
</ul>
<a name="attached-properties"></a>
<h2 id="attached-properties">Attached Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#desktopAvailableHeight-attached-prop">desktopAvailableHeight</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#desktopAvailableWidth-attached-prop">desktopAvailableWidth</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#devicePixelRatio-attached-prop">devicePixelRatio</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#height-attached-prop">height</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#manufacturer-attached-prop">manufacturer</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#model-attached-prop">model</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#name-attached-prop">name</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#orientation-attached-prop">orientation</a></b></b> : Qt::ScreenOrientation</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#orientationUpdateMask-attached-prop">orientationUpdateMask</a></b></b> : Qt::ScreenOrientations</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#pixelDensity-attached-prop">pixelDensity</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#primaryOrientation-attached-prop">primaryOrientation</a></b></b> : Qt::ScreenOrientation</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#serialNumber-attached-prop">serialNumber</a></b></b> : string</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#virtualX-attached-prop">virtualX</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#virtualY-attached-prop">virtualY</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-qtquick-window-screen.html#width-attached-prop">width</a></b></b> : int</li>
</ul>
<a name="attached-methods"></a>
<h2 id="attached-methods">Attached Methods</h2>
<ul>
<li class="fn">int <b><b><a href="qml-qtquick-window-screen.html#angleBetween-method">angleBetween</a></b></b>(Qt::ScreenOrientation <i>a</i>,  Qt::ScreenOrientation <i>b</i>)</li>
</ul>
<!-- $$$Screen-description -->
<a name="details"></a>
<h2 id="details">详细信息</h2>
<p>The Screen attached object is valid inside Item or Item derived types, after component completion. Inside these items it refers to the screen that the item is currently being displayed on.</p>
<p>The attached object is also valid inside Window or Window derived types, after component completion. In that case it refers to the screen where the Window was created. It is generally better to access the Screen from the relevant Item instead, because on a multi-screen desktop computer, the user can drag a Window into a position where it spans across multiple screens. In that case some Items will be on one screen, and others on a different screen.</p>
<p>To use this type, you will need to import the module with the following line:</p>
<pre class="cpp">

  import <span class="type">QtQuick</span><span class="operator">.</span>Window <span class="number">2.2</span>

</pre>
<p>It is a separate import in order to allow you to have a QML environment without access to window system features.</p>
<p>Note that the Screen type is not valid at Component.onCompleted, because the Item or Window has not been displayed on a screen by this time.</p>
<!-- @@@Screen -->
<h2>Attached Property Documentation</h2>
<!-- $$$desktopAvailableHeight -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="desktopAvailableHeight-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="desktopAvailableHeight-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.desktopAvailableHeight</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the available height of the collection of screens which make up the virtual desktop, in pixels, excluding window manager reserved areas such as task bars and system menus. If you want to position a Window at the bottom of the desktop, you can bind to it like this:</p>
<pre class="cpp">

  y: Screen<span class="operator">.</span>desktopAvailableHeight <span class="operator">-</span> height

</pre>
<p>This property was introduced in  Qt 5.1.</p>
</div></div><!-- @@@desktopAvailableHeight -->
<br/>
<!-- $$$desktopAvailableWidth -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="desktopAvailableWidth-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="desktopAvailableWidth-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.desktopAvailableWidth</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the available width of the collection of screens which make up the virtual desktop, in pixels, excluding window manager reserved areas such as task bars and system menus. If you want to position a Window at the right of the desktop, you can bind to it like this:</p>
<pre class="cpp">

  x: Screen<span class="operator">.</span>desktopAvailableWidth <span class="operator">-</span> width

</pre>
<p>This property was introduced in  Qt 5.1.</p>
</div></div><!-- @@@desktopAvailableWidth -->
<br/>
<!-- $$$devicePixelRatio -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="devicePixelRatio-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="devicePixelRatio-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.devicePixelRatio</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The ratio between physical pixels and device-independent pixels for the screen.</p>
<p>Common values are 1.0 on normal displays and 2.0 on Apple &quot;retina&quot; displays.</p>
<p>This property was introduced in  Qt 5.4.</p>
</div></div><!-- @@@devicePixelRatio -->
<br/>
<!-- $$$height -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="height-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="height-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.height</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the height of the screen in pixels.</p>
</div></div><!-- @@@height -->
<br/>
<!-- $$$manufacturer -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="manufacturer-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="manufacturer-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.manufacturer</span> : <span class="type"><a href="../qtqml/qml-string.html">string</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The manufacturer of the screen.</p>
<p>This property was introduced in  Qt 5.10.</p>
</div></div><!-- @@@manufacturer -->
<br/>
<!-- $$$model -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="model-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="model-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.model</span> : <span class="type"><a href="../qtqml/qml-string.html">string</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The model of the screen.</p>
<p>This property was introduced in  Qt 5.10.</p>
</div></div><!-- @@@model -->
<br/>
<!-- $$$name -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="name-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="name-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.name</span> : <span class="type"><a href="../qtqml/qml-string.html">string</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The name of the screen.</p>
<p>This property was introduced in  Qt 5.1.</p>
</div></div><!-- @@@name -->
<br/>
<!-- $$$orientation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="orientation-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="orientation-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.orientation</span> : <span class="type">Qt::ScreenOrientation</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the current orientation of the screen, from the accelerometer (if any). On a desktop computer, this value typically does not change.</p>
<p>If <a href="qml-qtquick-window-screen.html#primaryOrientation-attached-prop">primaryOrientation</a> == orientation, it means that the screen automatically rotates all content which is displayed, depending on how you hold it. But if orientation changes while <a href="qml-qtquick-window-screen.html#primaryOrientation-attached-prop">primaryOrientation</a> does NOT change, then probably you are using a device which does not rotate its own display. In that case you may need to use <a href="qml-qtquick-item.html#rotation-prop">Item.rotation</a> or <a href="qml-qtquick-item.html#transform-prop">Item.transform</a> to rotate your content.</p>
<p><b>Note: </b>This property does not update unless a <a href="qml-qtquick-window-screen.html#orientationUpdateMask-attached-prop">Screen::orientationUpdateMask</a> is set to a value other than <code>0</code>.</p></div></div><!-- @@@orientation -->
<br/>
<!-- $$$orientationUpdateMask -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="orientationUpdateMask-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="orientationUpdateMask-attached-prop"></a><span class="name">Screen.orientationUpdateMask</span> : <span class="type">Qt::ScreenOrientations</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the update mask for the orientation. <a href="qml-qtquick-window-screen.html#orientation-attached-prop">Screen::orientation</a> only emits changes for the screen orientations matching this mask.</p>
<p>By default it is set to the value of the <a href="../qtgui/qscreen.html">QScreen</a> that the window uses.</p>
<p>This property was introduced in  Qt 5.4.</p>
</div></div><!-- @@@orientationUpdateMask -->
<br/>
<!-- $$$pixelDensity -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="pixelDensity-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="pixelDensity-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.pixelDensity</span> : <span class="type"><a href="../qtqml/qml-real.html">real</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The number of physical pixels per millimeter.</p>
<p>This property was introduced in  Qt 5.2.</p>
</div></div><!-- @@@pixelDensity -->
<br/>
<!-- $$$primaryOrientation -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="primaryOrientation-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="primaryOrientation-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.primaryOrientation</span> : <span class="type">Qt::ScreenOrientation</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the primary orientation of the screen. If the screen's height is greater than its width, then the orientation is Qt.PortraitOrientation; otherwise it is Qt.LandscapeOrientation.</p>
<p>If you are designing an application which changes its layout depending on device orientation, you probably want to use primaryOrientation to determine the layout. That is because on a desktop computer, you can expect primaryOrientation to change when the user rotates the screen via the operating system's control panel, even if the computer does not contain an accelerometer. Likewise on most handheld computers which do have accelerometers, the operating system will rotate the whole screen automatically, so again you will see the primaryOrientation change.</p>
</div></div><!-- @@@primaryOrientation -->
<br/>
<!-- $$$serialNumber -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="serialNumber-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="serialNumber-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.serialNumber</span> : <span class="type"><a href="../qtqml/qml-string.html">string</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The serial number of the screen.</p>
<p>This property was introduced in  Qt 5.10.</p>
</div></div><!-- @@@serialNumber -->
<br/>
<!-- $$$virtualX -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="virtualX-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="virtualX-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.virtualX</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The x coordinate of the screen within the virtual desktop.</p>
<p>This property was introduced in  Qt 5.9.</p>
</div></div><!-- @@@virtualX -->
<br/>
<!-- $$$virtualY -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="virtualY-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="virtualY-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.virtualY</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The y coordinate of the screen within the virtual desktop.</p>
<p>This property was introduced in  Qt 5.9.</p>
</div></div><!-- @@@virtualY -->
<br/>
<!-- $$$width -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="width-attached-prop">
<td class="tblQmlPropNode"><p>
<a name="width-attached-prop"></a><span class="qmlreadonly">[read-only] </span><span class="name">Screen.width</span> : <span class="type"><a href="../qtqml/qml-int.html">int</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This contains the width of the screen in pixels.</p>
</div></div><!-- @@@width -->
<br/>
<h2>Attached Method Documentation</h2>
<!-- $$$angleBetween -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="angleBetween-method">
<td class="tblQmlFuncNode"><p>
<a name="angleBetween-method"></a><span class="type"><a href="../qtqml/qml-int.html">int</a></span> <span class="name">angleBetween</span>(<span class="type">Qt::ScreenOrientation</span> <i>a</i>,  <span class="type">Qt::ScreenOrientation</span> <i>b</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Returns the rotation angle, in degrees, between the two specified angles.</p>
</div></div><!-- @@@angleBetween -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
